package io.renren.uitls;

import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.junit.Test;

import java.io.IOException;

/**
 * @author: xiaomi
 * @date: 2021/8/9
 * @description:
 */
@Slf4j
public class Thumbnail {

    /**
     * 生成缩略图
     * https://www.php.cn/java/guide/457246.html
     * https://www.cnblogs.com/miskis/p/5500822.html
     * 到时候可能是做一个页面，提供压缩的接口；在表中保留原图和压缩图的关联关系（那么我之前写的 ThumbnailTask 就有出入了！）
     * 等页面出来再做吧！
     */
    @Test
    public void generateThumbnail() throws IOException {
        //图片路径
        String fromPic = "D:\\File\\Picture\\3.jpg";
        String toPic = "D:\\File\\Picture\\3thumbnail.jpg";
        //
        Thumbnails.of(fromPic).scale(1f).outputQuality(1f).toFile(toPic);

    }
}
